import { request } from '@/utils/request'
import { url } from './url'

// 用户相关API
export const userApi = {
  // 获取所有用户列表
  getUserList: (params) => request('get', `${url}/user`, null, params),

  // 获取单个用户信息
  getUserInfo: (userId) => request('get', `${url}/user/${userId}`),

  // 新增用户
  addUser: (userData) => request('post', `${url}/user`, userData),

  // 更新用户信息
  updateUserInfo: (userId, userData) => request('put', `${url}/user/${userId}`, userData),

  // 删除用户
  deleteUser: (userId) => request('delete', `${url}/user/${userId}`),

  // 获取用户角色
  getUserRoles: (userId) => request('get', `${url}/user/${userId}/roles`),

  // 修改密码
  changePassword: (userId, passwordData) => request('put', `${url}/user/${userId}/password`, passwordData),

  // 上传头像
  uploadAvatar: (userId, formData) => request('post', `${url}/user/${userId}/avatar`, formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// export default api
